/**
 * Created by oscar-yang on 2015/12/30.
 */
angular.module('header', ['security'])
    .controller('headerController', ['$scope', '$timeout', '$state', 'security', function ($scope, $timeout, $state, security) {

        // 返回当前用户
        $timeout(function () {
            $scope.currentUser = security.currentUser;
        }, 300);

        // 设置注销功能
        $scope.logout = function () {
            security.logout().then(function (result) {
                if (!result) {
                    $state.go('login');
                }
            });
        };
    }]);

